import { middleLogger } from '@/utils/back/devlogger';
import { pathsToRegs } from '@/utils/common';
import { NextRequest, NextResponse } from 'next/server';

export default function fallbackMiddleware(req: NextRequest, next: Fn) {
  const pathname = req.nextUrl.pathname;
  middleLogger.info('fallbackMiddleware', pathname);

  const newDomainResponse = (domain: string) => {
    const url = pathname + req.nextUrl.search;
    return NextResponse.rewrite(new URL(url, domain));
  };

  return newDomainResponse(process.env.NEXT_PUBLIC_DSZ_DOMAIN!);
}
